#include "String_Manip.h"
#include <stdio.h>


void* GetWord(char** src)
{
	char* pos;
	char* start = *src;
	if(*src == NULL)
		return NULL;
	pos = (char*)memchr(*src,' ',strlen(*src));
	if(pos == NULL)
		return NULL;
	*pos = '\0';
	*src = pos+1;
	return start;
}

void* GetSentence(char** src)
{
	char* pos;
	char* start = *src;
	int str_len;
	if(*src == NULL)
		return NULL;
	str_len = strlen(*src);
	pos = (char*)memchr(*src,'\n',str_len);
	if(pos == NULL)
		return NULL;
	*pos = '\0';
	*src = pos+1;
	return start;
}

void* GetFilename(const char* fullpathname)
{
	char* save_name, *pos;
	int name_len;
	name_len = strlen(fullpathname);
	pos = fullpathname + name_len;
	while(*pos != '/' && pos != fullpathname)
	    pos --;
	if(pos == fullpathname)
	{
		save_name = fullpathname + 1;
		return save_name;
	}
	name_len = name_len-(pos-fullpathname);
	save_name = (char*) malloc(name_len+1);
	memcpy(save_name,pos+1,name_len);
	return save_name;
}
